package com.zxl.finance.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;

/**
 * @auther: zxl
 * @creater: 2018-07-13
 * @description: swagger的配置类.  用@Configuration注解该类，等价于XML中配置beans；用@Bean标注方法等价于XML中配置bean
 **/
@Configuration
public class Swagger2Config {

    @Bean
    public Docket createRestApi(){
        return new Docket(DocumentationType.SWAGGER_2)
                .apiInfo(apiInfo())
                .select()
                .apis(RequestHandlerSelectors.basePackage("com.zxl.finance"))
                .paths(PathSelectors.any())
                .build();
    }

    private ApiInfo apiInfo() {
        return new ApiInfoBuilder()
                .title("financeInfo利用swagger构建api文档")
                .description("用swagger创建restful风格的financeInfo的api文档")
                .termsOfServiceUrl("http://省略```")
                .version("1.0")
                .build();
    }

}
